﻿package environment{	import environment.StarField;		import flash.display.BitmapData;	import flash.geom.Point;		import flash.display.BlendMode;		public class Background extends StarField	{		public function Background($width:uint = 800, $height:uint = 600)		{			w = $width;			h = $height;						var bs:uint = 16;			const size:uint = 509;						if (!stars)			{				stars = new BitmapData(size*4, size*4, false);								var ox:uint = 0;				var oy:uint = 0;				while(bs--)				{					var bd:BitmapData = Main.bulk.getBitmapData("bg"+(1 + uint(Math.random()*5)));					var p:Point = new Point(ox*size, oy*size);					stars.copyPixels(bd, bd.rect, p);					ox++;					if (ox == 4)					{						ox = 0;						oy++;					}				}				var noise:BitmapData = new BitmapData(size*4, size*4, false);				noise.perlinNoise(size, size, 6, 123, true, true, 4, true);				stars.draw(noise, null, null, BlendMode.OVERLAY);			}						super(w, h);						redraw();		}	}}